<?php

namespace App\Models;



class MallOrderProductSnapshot extends Base
{
    const PAID_SUCCESS = 1;

    const PAY_TYPE_WX = 2;
    const PAY_TYPE_ALI = 1;

    public $guarded = ['fare_yuan'];

//    protected $appends = [ 'paid_amount_yuan'];

    protected $casts = [
        'specs_detail' => 'array',
        'specs_detail_info' => 'array',
        'image_url' => 'array',
        'video_url' => 'array',
    ];

    public function setSpecsDetailAttribute($val) {
        return $this->attributes['specs_detail'] = json_encode_cn($val);
    }


//    public function getPaidAmountYuanAttribute() {
//        return format_yuan($this->amount);
//    }

    public function user() {
        return $this->belongsTo(User::class, 'user_id');
    }

    public function category() {
        return $this->belongsTo(Category::class, 'category_id');
    }

    public function setImageUrlAttribute($val) {
        $this->attributes['image_url'] = $val;
    }

    public function setVideoUrlAttribute($val) {
        $this->attributes['video_url'] = $val;
    }
}
